﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Core
{
    public static partial class user
    {
        public static dynamic getUserList(int start, int limit)
        {
            var sql = new Sql.SqlDataContext();
            var total = sql.User.Count();
            var result = (from u in sql.User
                          orderby u.regTime descending
                          select new
                          {
                              u.username,
                              u.nickname,
                              u.email,
                              u.sid,
                              u.school,
                              sex = u.sex.toSex(),
                              birthday = u.birthday.toDateString(),
                              u.publicPersonalInfo,
                              u.disabled,
                              u.admin
                          }).Skip(start).Take(limit);
            return new
            {
                success = true,
                total,
                result
            };
        }
    }
}
